<?php 
$sort1=isset($_GET['sort'])?'&sort='.$_GET['sort']:'';
$cs=Yii::app()->clientScript;
$cs->registerScript('appointment_excel',<<<END
$("#excel").click(
function(){
	var act=$("form").attr('action');
	$("form").attr('action',act+'&excel=1$sort1');
	$("form").attr('target','_blank');
	$("form").submit();
	$("form").attr('action',act);
	$("form").attr('target','');
}
);
END
);
?>
<?php if($search):?>
<h2>查询确认单</h2>
<?php else:?>
<h2>修改确认单</h2>
<?php endif?>
<?php echo CHtml::beginForm(array($search?'search':'admin'),'post');?>
<table  style="margin: 0 auto;"  width="1270">
<tr><td>
	确认单号：<input type="text" name="keys[confirm_no]" size="9" value="<?php echo isset($_GET['keys']['confirm_no'])?$_GET['keys']['confirm_no']:'';?>"/>
	行驶状态：<?php echo CHtml::dropDownList('keys[loading_status]', isset($_GET['keys']['loading_status'])?$_GET['keys']['loading_status']:'', array(''=>'全部','0'=>'重驶','1'=>'指定空驶'));?>
	车牌号：<input type="text" name="keys[truck_plate_no]" size="7" value="<?php echo isset($_GET['keys']['truck_plate_no'])?$_GET['keys']['truck_plate_no']:'';?>"/>
	司机1：<input type="text" name="keys[driver1_name]" size="7" value="<?php echo isset($_GET['keys']['driver1_name'])?$_GET['keys']['driver1_name']:'';?>"/>
	业务时间：<input type="text" id="keys[s_date]" name="keys[s_date]" size="7" value="<?php echo isset($_GET['keys']['s_date'])?$_GET['keys']['s_date']:'';?>"/>
	<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'keys[s_date]','ifFormat'=>'%Y-%m'));?>
	模糊查询：<input type="radio" name="keys[blur]" value="1" checked/>是  
	<input type="radio" name="keys[blur]" value="0" <?php echo isset($_GET['keys']['blur'])&&$_GET['keys']['blur']==0?'checked':'';?>/>否 
	<input type="submit" value="搜索"/>&nbsp;&nbsp;&nbsp;&nbsp;<input id="excel" type="button" value="输出excel文件"/>
	<br/>收入费用:<?php echo CHtml::dropDownList('keys[amount_cost]', isset($_GET['keys']['amount_cost'])?$_GET['keys']['amount_cost']:'', array(''=>'全部','0'=>'未填写','1'=>'已填写'));?>
</td></tr></table>
<?php echo CHtml::endForm();?>
<table class="dataGrid" width="1270">
  <thead>
  <tr>
    <th width="90"><?php echo $sort->link('confirm_no'); ?></th>
    <th width="70"><?php echo $sort->link('loading_status'); ?></th>
    <th width="70"><?php echo $sort->link('truck_plate_no'); ?></th>
    <th width="80"><?php echo $sort->link('board_plate_no'); ?></th>
    <th width="70"><?php echo $sort->link('type'); ?></th>
    <th width="80"><?php echo $sort->link('driver1_name'); ?></th>
    <th width="100"><?php echo $sort->link('consignor_name'); ?></th>
    <th width="100"><?php echo $sort->link('consignee_name'); ?></th>
    <th width="80"><?php echo $sort->link('goods_name'); ?></th>
    <th width="80"><?php echo $sort->link('origin'); ?></th>
    <th width="80"><?php echo $sort->link('destination'); ?></th>
    <th width="80"><?php echo $sort->link('goods_demand_deliver_time'); ?></th>
    <th width="80"><?php echo $sort->link('appointment_time'); ?></th>
    <th width="140"><?php echo $sort->link('create_time'); ?></th>
	<?php if(!$search):?><th  width="70">操作</th><?php endif ?>
  </tr>
  </thead>
  <tbody>
<?php foreach($models as $n=>$model): ?>
  <tr class="<?php echo $n%2?'even':'odd';?>">
    <?php 
    	$url=array('show','id'=>$model->id)+$_GET;//把所有参数包括页码、查询参数传入显示信息页面
    	$url['ret']=$search?'search':'admin';
    ?>
    <td><?php echo CHtml::link($model->confirm_no,$url); ?></td>
    <td><?php echo CHtml::encode($model->getLoadingStatusName()); ?></td>
    <td><?php echo CHtml::encode($model->truck_plate_no); ?></td>
    <td><?php echo CHtml::encode($model->board_plate_no); ?></td>
    <td><?php echo CHtml::encode($model->type); ?></td>
    <td><?php echo CHtml::encode($model->driver1_name); ?></td>
    <td><?php echo CHtml::encode($model->consignor_name); ?></td>
    <td><?php echo CHtml::encode($model->consignee_name); ?></td>
    <td><?php echo CHtml::encode($model->goods_name); ?></td>
    <td><?php echo CHtml::encode($model->origin); ?></td>
    <td><?php echo CHtml::encode($model->destination); ?></td>
    <td><?php echo CHtml::encode(substr($model->goods_demand_deliver_time,0,10)); ?></td>
    <td><?php echo CHtml::encode($model->appointment_time); ?></td>
    <td><?php echo CHtml::encode($model->create_time); ?></td>
    <?php if(!$search):?>
    <td>
      <?php echo CHtml::link('修改',array('update','id'=>$model->id)+$_GET); ?>
     <?php echo CHtml::link('删除',array('delete','id'=>$model->id)+$_GET,array('confirm'=>"确定要删除确认单号：{$model->confirm_no} 的确认单吗？")); ?>
	</td>
	<?php endif ?>
  </tr>
<?php endforeach; ?>
  </tbody>
</table>
<br/>
<?php $this->widget('CLinkPager',array('pages'=>$pages,'htmlOptions'=>array('style'=>'width:1270px;'))); ?>
